<?php

class UserModel extends Model{
	
	protected $trueTableName = "csl_user";
	
	
	function getAllChildrenUser($uid,$type='1'){
		$info = $this->where(array('uid'=>$uid))->find();
		
		$list = $this->where(array('path'=>array('like',$info['path']."%")))->limit(0,1000)->select();
		
		if($type!='1'){
			return $list;
		}else{
			$uarr = array();
			foreach($list as $key=>$value){
				$uarr[] = $value['uid'];
			}
			return $uarr;
		}
	}
	
	//获取树形结构
	function getChildrenTree() {
		$result = $this->limit(0,1000)->select();
		
		foreach($result as $k=>$v) {
			$long = 0;
			$long = strlen($v['path'])/6-1;
			
			$str = '';
			if($long>0) { 
				for($i=0;$i<$long;$i++) {
					$str.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
				}
				$str.= "└";
			}
			$result[$k]['space'] = $str;
		}
		
		return $result;
	}
	
}

?>